//
//  nightTabBarViewController.m
//  soccer
//
//  Created by 上官千城 on 15/9/2.
//  Copyright (c) 2015年 上官千城. All rights reserved.
//

#import "OBaseTabBarViewController.h"

@interface OBaseTabBarViewController ()

@end

@implementation OBaseTabBarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
//    ConsultViewController *consult = [[ConsultViewController alloc]init];
//    nightNavViewController *consultNav = [[nightNavViewController alloc]initWithRootViewController:consult];
//    consultNav.tabBarItem = [[UITabBarItem alloc]init];
//    
//    
//    CircleViewController *circle = [[CircleViewController alloc]init];
//    nightNavViewController *circleNav = [[nightNavViewController alloc]initWithRootViewController:circle];
//    circleNav.tabBarItem = [[UITabBarItem alloc]init];
//    
//    FriendViewController *friend = [[FriendViewController alloc]init];
//    nightNavViewController *friendNav = [[nightNavViewController alloc]initWithRootViewController:friend];
//    friendNav.tabBarItem = [[UITabBarItem alloc]init];
//    
//    SettingViewController *setting = [[SettingViewController alloc]init];
//    nightNavViewController *settingNav = [[nightNavViewController alloc]initWithRootViewController:setting];
//    settingNav.tabBarItem = [[UITabBarItem alloc]init];
//    
//    self.tabBar.translucent = NO;
//    self.viewControllers = [NSArray arrayWithObjects:consultNav,circleNav,friendNav,settingNav, nil];
    
//    LeftViewController *leftMenuViewController = [[LeftViewController alloc] init];
//    RESideMenu *sideMenuViewController = [[RESideMenu alloc] initWithContentViewController:self leftMenuViewController:leftMenuViewController rightMenuViewController:nil];
//    sideMenuViewController.backgroundImage = [UIImage imageNamed:@"Stars"];
//    sideMenuViewController.menuPreferredStatusBarStyle = 1; 
//    sideMenuViewController.delegate = self;
//    sideMenuViewController.contentViewShadowColor = [UIColor blackColor];
//    sideMenuViewController.contentViewShadowOffset = CGSizeMake(0, 0);
//    sideMenuViewController.contentViewShadowOpacity = 0.6;
//    sideMenuViewController.contentViewShadowRadius = 12;
//    sideMenuViewController.contentViewShadowEnabled = YES;
//    self.window.rootViewController = sideMenuViewController;

    
    
    NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
    
    if ([@"on" isEqualToString:[userDefaults objectForKey:@"isNight"]]) {
        
        //    夜间模式
        self.tabBar.barTintColor=[UIColor colorWithRed:27 / 255.0 green:27 / 255.0 blue:27 / 255.0 alpha:1.0];
        NSMutableDictionary *textAttr = [NSMutableDictionary dictionary];
        textAttr[NSForegroundColorAttributeName] = [UIColor whiteColor];
        
        NSMutableDictionary *selectTextAttr = [NSMutableDictionary dictionary];
        selectTextAttr[NSForegroundColorAttributeName] = [UIColor blueColor];
        [self.tabBarItem setTitleTextAttributes:textAttr forState:UIControlStateNormal];
        [self.tabBarItem setTitleTextAttributes:selectTextAttr forState:UIControlStateSelected];
        self.tabBar.tintColor = [UIColor whiteColor];
        
    } else {
        
        self.tabBar.barTintColor=[UIColor colorWithRed:0 / 255.0 green:186 / 255.0 blue:170 / 255.0 alpha:1.0];
        NSMutableDictionary *textAttr = [NSMutableDictionary dictionary];
        textAttr[NSForegroundColorAttributeName] = [UIColor whiteColor];
        
        NSMutableDictionary *selectTextAttr = [NSMutableDictionary dictionary];
        selectTextAttr[NSForegroundColorAttributeName] = [UIColor blueColor];
        [self.tabBarItem setTitleTextAttributes:textAttr forState:UIControlStateNormal];
        [self.tabBarItem setTitleTextAttributes:selectTextAttr forState:UIControlStateSelected];
        self.tabBar.tintColor = [UIColor blueColor];
        
    }
    
    NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
    [notificationCenter addObserver:self selector:@selector(changeNight:) name:@"changeNight" object:nil];
    
    

    
}

-(void)nightChange {
    [self.myDelegate nightChange];
    NSLog(@"2222");
    
}

-(void)changeNight:(NSNotification *)notification {
    
    
    NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
    if ([@"on" isEqualToString:[userDefaults objectForKey:@"isNight"]]) {
        
        self.tabBar.barTintColor=[UIColor colorWithRed:27 / 255.0 green:27 / 255.0 blue:27 / 255.0 alpha:1.0];
        NSMutableDictionary *textAttr = [NSMutableDictionary dictionary];
        textAttr[NSForegroundColorAttributeName] = [UIColor whiteColor];
        
        NSMutableDictionary *selectTextAttr = [NSMutableDictionary dictionary];
        selectTextAttr[NSForegroundColorAttributeName] = [UIColor blueColor];
        [self.tabBarItem setTitleTextAttributes:textAttr forState:UIControlStateNormal];
        [self.tabBarItem setTitleTextAttributes:selectTextAttr forState:UIControlStateSelected];
        self.tabBar.tintColor = [UIColor whiteColor];
    } else {
        
        self.tabBar.barTintColor=[UIColor colorWithRed:0 / 255.0 green:186 / 255.0 blue:170 / 255.0 alpha:1.0];
        NSMutableDictionary *textAttr = [NSMutableDictionary dictionary];
        textAttr[NSForegroundColorAttributeName] = [UIColor whiteColor];
        
        NSMutableDictionary *selectTextAttr = [NSMutableDictionary dictionary];
        selectTextAttr[NSForegroundColorAttributeName] = [UIColor blueColor];
        [self.tabBarItem setTitleTextAttributes:textAttr forState:UIControlStateNormal];
        [self.tabBarItem setTitleTextAttributes:selectTextAttr forState:UIControlStateSelected];
        self.tabBar.tintColor = [UIColor blueColor];
        
    }
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
